$(function(){
	//删除用户
	$(".delete").each(function(){
		$(this).click(function(){
			alert(100);
			var pp=$(this).parent().parent().parent();
			var id=pp.children().eq(1).html();
			$.ajax({
				type:'post',
				url:"/yh/user103",
				data:{"user_id":id},	
				success:function(data){	
					pp.remove();
				}
			})
		});
	});
	
	
	$("#ajaxadd").click(function(){
		$("#ajaxAdd").show();
		
	})

	$(".page").click(function(){
		var num=this.innerHTML;
		 num =parseInt(num);
			 $(".page").each(function(id){
				 var i=this.innerHTML;
				 i =parseInt(i);
				 this.innerHTML=i+1;
				 $(this).parent().removeClass('am-active');
				 if(this.innerHTML==num){
			     $(this).parent().addClass('am-active'); 
				 } 
		})	 
	})
	
	var currentPageNum=$("#currentPageNum").html();
	$.ajax({
		type:'post',
		url:'/yh/user105',
		data:{"currentPageNum":currentPageNum},
		
		success:function(data){
			var json = eval("("+data+")");
			var u_list="";
			$("#p1").html(json.countUser);
			$("#p2").html(json.pageCount)
			$.each(json.u_list,function(n,value){
				u_list +="<tr><td><input type='checkbox' /></td><td>"+value.user_id+"</td>"
						+"<td><a href='#'>"+value.user_name+"</a></td><td>"+value.user_pwd+"</td>"
						+"<td class='am-hide-sm-only'>"+value.sex+"</td>"
						+"<td class='am-hide-sm-only'>"+value.file_id+"</td>"
						+"<td><div class='am-btn-group am-btn-group-xs'>"
						+"<button class='am-btn am-btn-default am-btn-xs am-text-secondary'><span class='am-icon-pencil-square-o'></span> 编辑</button>"
						+"<button class='am-btn am-btn-default am-btn-xs am-hide-sm-only'><span class='am-icon-copy'></span> 复制</button>"
						+"<button class='am-btn am-btn-default am-text-danger delete' ><span class='am-icon-trash-o'></span> 删除</button></div></td></tr>";
			})
			$("#list").append(u_list);
		}
		
	})

	$(".table-main").on("click",".delete",function(){
		alert(22);
	})

});
	
